package com.project.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CommonResponse {
    // 表明对应请求的返回处理结果 "success"或"fail"
    private String status;

    // status=success,data内返回前段需要的json数据
    // status=fail,data内使用通用的错误码格式
    private Object data;

    // 定义一个通用的创建方法
    public static CommonResponse create(Object result){
        return CommonResponse.create(result,"success");
    }

    public static CommonResponse create(Object result, String status){
        CommonResponse type = new CommonResponse();
        type.setStatus(status);
        type.setData(result);
        return type;
    }


}

